/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package parsertojaklin;

import com.mysql.jdbc.Statement;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Collections;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Vector;

/**
 *
 * @author Юра
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws SQLException, FileNotFoundException, IOException {
        //MySQLconnect mysql = new MySQLconnect("u218164", "penta9ecal", "u218164.mysql.masterhost.ru/u218164" );
        MySQLconnect mysql = new MySQLconnect("root", "schizoid", "localhost/cancelary" );
        Statement s = mysql.getStatem();

        //mysql.TrunkVendors();
        //LinkedList<String> vendors = Vendor.parse_vendors();
        //mysql.InsertVendors(vendors);

        Hashtable<String, Wares> wareses = new Hashtable<String, Wares>();
        Hashtable<String, Group> groups = new Hashtable<String, Group>();

//katalog.php-grupp_kod=100069&otobr=1&count_fl=6&brend_from_head=ДЕЛЬТА
//file:///D:/projects/optvideo/optvideo/optvideo.com/new_design/new_kat/katalog/wares_group/view.php-kod=121862.htm
        s.executeUpdate ("TRUNCATE TABLE `groups`");
        groups = Group.parse_groups(s);

        wareses = Wares.parse_wares(s);

           // order wareses
        Vector v = new Vector(groups.keySet());
        Collections.sort(v);
        Iterator it = v.iterator();
        int c = 0;
        while(it.hasNext()){
            c++;
            String key = (String) it.next();
            System.out.println(c+"- "+key+" _ "+groups.get(key).name_group);
            s.executeUpdate(groups.get(key).insert_string());
        }
//parser.wares_in_dir(s);
         
         

        //System.out.println(groups.size());
    }

}
